package com.husky.easyexcle.controller;


import com.husky.easyexcle.service.ExcelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;


/**
 * @author huanfuan
 * @date 2023/5/26 16:58
 */

@RestController
@Slf4j
public class ExceJoblController {

    @Autowired
    private ExcelService excelServiceImpl;


    /**
     *
     * C.导入etl_job-dep.xlsx文件生成作业依赖.xlsx
     *
     * 读取上传Excel数据
     * @param file
     * @return
     * @throws IOException
     */
    @PostMapping("read/dep/data")
    public void readExcelDepData(MultipartFile file) {
        log.info("读取上传Excel开始。file={}",file);
        try {
            excelServiceImpl.readExcelDepData(file);
            log.info("list={}");
        }catch (Exception e){
            log.error("读取上传Excel异常。Exception={}",e);
        }

    }






    /**
     *
     * A. 导入etl_job-all.xlsx文件生成作业流_作业.xlsx
     *
     * 读取加工任务Excel数据
     * @param file
     * @return
     * @throws IOException
     */
    @PostMapping("read/job/data")
    public void readJobDepData(MultipartFile file) {
        log.info("读取上传Excel开始。file={}",file);
        try {
            excelServiceImpl.readExcelJobData(file);
            log.info("list={}");
        }catch (Exception e){
            log.error("读取上传Excel异常。Exception={}",e);
        }

    }



}
